// TCPSocketServer.h

#pragma once

#include "TCPSocketDef.h"

class FrameBufferQueue;

class TCPSocketServer
{
public:
    TCPSocketServer(void);
    ~TCPSocketServer(void);

public:
    DWORD OpenTCP(void* pOwner, std::string strServerHost, int serverPort);
    DWORD CloseTCP(void);
    DWORD SaveData(LPVOID* data);
    DWORD GetData(LPVOID* data);

private:
    static UINT CALLBACK AcceptThread(LPVOID lParam);
    static UINT CALLBACK ReceiveThread(LPVOID lParam);

private:
    SOCKET m_socketTCP;
    SOCKET m_socketConnect;
    SOCKADDR_IN m_sockaddrin;
    HANDLE m_hExitThreadEvent;
    void* m_pOwner;
    char* m_recvBuf;
    FrameBufferQueue* m_fbqBuf;

public:
    TCP_ERROR_CALLBACK m_OnTCPError;
    TCP_ACCEPT_CALLBACK m_OnTCPAccept;
    TCP_RECEIVE_CALLBACK m_OnTCPRecv;
    TCP_CALL_CALLBACK m_OnTCPCall;
};
